//封装的是具体的接口请求方法
//每个方法只负责请求一个url地址
import request from '@/utils/request'
import store from '@/store'
//导出注册接口方法
export const registerAPI = (obj) => {
return request({
  url:'/api/reg',
  method:'POST',
  data:obj
 })
}
//登录接口
export const loginAPI =(obj)=>{
  return request({
    url:'/api/login',
    method:'POST',
    data:obj
   })
}

//获取用户接口
export const getUserInfoAPI=()=>{
  return request({
    url:'/my/userinfo',
  })
}

//获取侧边栏数据
export const getMenusListAPI=()=>{
  return request({
    url:'/my/menus',
  })
}
//更新用户信息
export const updateUserInfoAPI=(obj)=>{
  return request({
    url:'/my/userinfo',
    method:'PUT',
    data:obj
  })
}
//更新用户头像
export const updateUserAvatarAPI=(avatar)=>{
  return request({
    url:'/my/update/avatar',
    method:'PATCH',
    data:{
      avatar
    }
  })
}
//修改密码的接口
export const updateUserPwdAPI=(obj)=>{
  return request({
    url:'/my/updatepwd',
    method:'PATCH',
    data:obj
  })
}
//获取文章列表的数据
export const getArtCateListAPI=()=>{
  return request({
    url:'/my/cate/list',
  })
}
//提交文章分类
export const saveArtCateAPI=(obj)=>{
  return request({
    url:'/my/cate/add',
    method:'POST',
    data:obj
  })
}
//更新文章分裂接口
export const updateArtCateAPI=(obj)=>{
  return request({
    url:'/my/cate/info',
    method:'PUT',
    data:obj
  })
}
//删除文章
export const delArtCateAPI=(id)=>{
  return request({
    url:'/my/cate/del',
    method:'DELETE',
    params:{
      id
    }
  })
}
//发布文章
export const uploadArticleAPI=(obj)=>{
  return request({
    url:'/my/article/add',
    method:'POST',
    data:obj
  })
}
//请求文章数据
export const getArtListAPI=({pagenum,pagesize,cate_id,state})=>{
  return request({
    url:'/my/article/list',
    params:{
      pagenum,
      pagesize,
      cate_id,
      state
    }

  })
}
//获取文章详情
export const getArtDetailAPI=(id)=>{
  return request({
    url:'/my/article/info',
    params:{
      id
    }
  })
}